<?php
namespace app\shop\controller;

use think\Controller;

class Index extends Controller
{
    public function __construct()
    {
        parent::__construct();

        $this->ProductModel = model('Product.Product');
        $this->TypeModel = model('Product.Type');
        $this->CartModel = model('Product.Cart');
        $this->BusinessModel = model('Business.Business');
    }

    //首页数据
    public function index()
    {
        if($this->request->isPost())
        {
            //轮播图 - flag = 3 推荐
            $top = $this->ProductModel->where(['flag' => '3'])->limit(5)->select();

            //分类
            $type = $this->TypeModel->limit(8)->select();

            //新品首页
            $news = $this->ProductModel->where(['flag' => '1'])->limit(8)->select();
            
            $data = [
                'top' => $top,
                'type' => $type,
                'news' => $news,
            ];

            $this->success('首页数据', null, $data);
            exit;
        }
    }
}
